<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>GSoC2011SfM: D:/Travail/These/Determination caracteristiques camera/GSoC/SfM/src/CameraPinholeDistor.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">GSoC2011SfM
   &#160;<span id="projectnumber">0.1</span>
   </div>
   <div id="projectbrief">Google Summer of Code 2011: Structure from motion</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">D:/Travail/These/Determination caracteristiques camera/GSoC/SfM/src/CameraPinholeDistor.cpp</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;CameraPinholeDistor.h&quot;</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="keyword">using</span> std::vector;
<a name="l00004"></a>00004 <span class="keyword">using</span> cv::Mat;
<a name="l00005"></a>00005 <span class="keyword">using</span> cv::Vec2d;
<a name="l00006"></a>00006 <span class="keyword">using</span> cv::Vec3d;
<a name="l00007"></a>00007 <span class="keyword">using</span> cv::Vec4d;
<a name="l00008"></a>00008 <span class="keyword">using</span> cv::Vec6d;
<a name="l00009"></a>00009 
<a name="l00010"></a>00010 <span class="keyword">namespace </span>OpencvSfM{
<a name="l00011"></a>00011 
<a name="l00012"></a><a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad58c8fb16fdbb0eba4345cd3abe47a92">00012</a>   <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad58c8fb16fdbb0eba4345cd3abe47a92">CameraPinholeDistor::CameraPinholeDistor</a>( cv::Mat intra_params,
<a name="l00013"></a>00013     cv::Vec6d radial_dist, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> nbRadialParam,
<a name="l00014"></a>00014     cv::Vec2d tangential_dist, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> wantedEstimation )
<a name="l00015"></a>00015     :<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html" title="This class represent the physical device which take the pictures. It is not related to a 3D position ...">CameraPinhole</a>( intra_params,wantedEstimation )
<a name="l00016"></a>00016   {
<a name="l00017"></a>00017     <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#aab95df60504b6bda45c11b53f939ad21">updateDistortionParameters</a>( radial_dist,nbRadialParam,tangential_dist );
<a name="l00018"></a>00018   }
<a name="l00019"></a>00019 
<a name="l00020"></a><a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ab3f32742332ecaab124721e9b259f932">00020</a>   <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad58c8fb16fdbb0eba4345cd3abe47a92">CameraPinholeDistor::CameraPinholeDistor</a>( 
<a name="l00021"></a>00021     <span class="keyword">const</span> std::vector&lt; std::vector&lt; cv::Point3f&gt; &gt;&amp; objectPoints,
<a name="l00022"></a>00022     <span class="keyword">const</span> std::vector&lt; std::vector&lt; cv::Point2f&gt; &gt;&amp; imagePoints,
<a name="l00023"></a>00023     cv::Size imageSize, <span class="keywordtype">double</span> aspectRatio<span class="comment">/*=1.*/</span>,
<a name="l00024"></a>00024     cv::Vec6d radial_dist, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> nbRadialParam,
<a name="l00025"></a>00025     cv::Vec2d tangential_dist, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> wantedEstimation )
<a name="l00026"></a>00026     :<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html" title="This class represent the physical device which take the pictures. It is not related to a 3D position ...">CameraPinhole</a>( objectPoints,imagePoints,imageSize,aspectRatio,wantedEstimation )
<a name="l00027"></a>00027   {
<a name="l00028"></a>00028     <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#aab95df60504b6bda45c11b53f939ad21">updateDistortionParameters</a>( radial_dist,nbRadialParam,tangential_dist );
<a name="l00029"></a>00029   }
<a name="l00030"></a>00030   CameraPinholeDistor::~CameraPinholeDistor( )
<a name="l00031"></a>00031   {
<a name="l00032"></a>00032     <span class="comment">//TODO</span>
<a name="l00033"></a>00033   }
<a name="l00034"></a>00034 
<a name="l00035"></a><a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#aab95df60504b6bda45c11b53f939ad21">00035</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#aab95df60504b6bda45c11b53f939ad21">CameraPinholeDistor::updateDistortionParameters</a>(
<a name="l00036"></a>00036     <span class="keyword">const</span> cv::Vec6d&amp; radial_dist, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> nbRadialParam,
<a name="l00037"></a>00037     <span class="keyword">const</span> cv::Vec2d&amp; tangential_dist,<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> wantedEstimation )
<a name="l00038"></a>00038   {
<a name="l00039"></a>00039     this-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html#a024b01688fee19c5c2d592f4060d6063">estimation_needed_</a>= ( this-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html#a024b01688fee19c5c2d592f4060d6063">estimation_needed_</a> &amp; 0x0F ) | ( wantedEstimation &amp; 0xF0 );
<a name="l00040"></a>00040     this-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>=radial_dist;
<a name="l00041"></a>00041     this-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#a99247804700d8c8bfaf50a4e84cfb080" title="number of radial dist parameters ( 0, 2, 3 or 6 )">nb_radial_params_</a>=nbRadialParam;
<a name="l00042"></a>00042     this-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ae09ea3c12a8e19788d084b357f11a902" title="used to store tangential dist parameters ( /f$p_1/f$ and /f$p_2/f$ )">tangential_dist_</a>=tangential_dist;
<a name="l00043"></a>00043     <span class="keywordflow">if</span>( <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html#a024b01688fee19c5c2d592f4060d6063">estimation_needed_</a>&amp;RADIAL_PARAM )
<a name="l00044"></a>00044     {
<a name="l00045"></a>00045       <span class="keywordtype">int</span> nbParamTotal=<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#a99247804700d8c8bfaf50a4e84cfb080" title="number of radial dist parameters ( 0, 2, 3 or 6 )">nb_radial_params_</a> + ( (<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html#a024b01688fee19c5c2d592f4060d6063">estimation_needed_</a>&amp;TANGEANT_PARAM )&gt;&gt;4 );
<a name="l00046"></a>00046       <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#af9ce33321472dbbb71668b266225060b" title="vector of distortion coefficients ( k_1, k_2, p_1, p_2[ , k_3[ , k_4, k_5, k_6 ]] ) of 4...">distortionVector</a>.create( nbParamTotal,1,CV_64F );<span class="comment">//( k_1, k_2, p_1, p_2[ , k_3[ , k_4, k_5, k_6 ]] )</span>
<a name="l00047"></a>00047       <span class="keywordtype">double</span> * vals=( <span class="keywordtype">double</span>* )<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#af9ce33321472dbbb71668b266225060b" title="vector of distortion coefficients ( k_1, k_2, p_1, p_2[ , k_3[ , k_4, k_5, k_6 ]] ) of 4...">distortionVector</a>.data;
<a name="l00048"></a>00048       vals[ 0 ]=<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[ 0 ];
<a name="l00049"></a>00049       vals[ 1 ]=<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[ 1 ];
<a name="l00050"></a>00050       <span class="keywordflow">if</span>( <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html#a024b01688fee19c5c2d592f4060d6063">estimation_needed_</a>&amp;TANGEANT_PARAM )
<a name="l00051"></a>00051       {
<a name="l00052"></a>00052         vals[ 2 ]=<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ae09ea3c12a8e19788d084b357f11a902" title="used to store tangential dist parameters ( /f$p_1/f$ and /f$p_2/f$ )">tangential_dist_</a>[ 0 ];
<a name="l00053"></a>00053         vals[ 3 ]=<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ae09ea3c12a8e19788d084b357f11a902" title="used to store tangential dist parameters ( /f$p_1/f$ and /f$p_2/f$ )">tangential_dist_</a>[ 1 ];
<a name="l00054"></a>00054         <span class="keywordflow">if</span>( nbRadialParam&gt;4 )
<a name="l00055"></a>00055         {
<a name="l00056"></a>00056           vals[ 4 ]=<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[ 2 ];
<a name="l00057"></a>00057           <span class="keywordflow">if</span>( nbRadialParam&gt;5 )
<a name="l00058"></a>00058           {
<a name="l00059"></a>00059             vals[ 5 ]=<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[ 3 ];
<a name="l00060"></a>00060             vals[ 6 ]=<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[ 4 ];
<a name="l00061"></a>00061             vals[ 7 ]=<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[ 5 ];
<a name="l00062"></a>00062           }
<a name="l00063"></a>00063         }
<a name="l00064"></a>00064       }
<a name="l00065"></a>00065     }
<a name="l00066"></a>00066   }
<a name="l00067"></a>00067 
<a name="l00068"></a><a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad78028097b1c964cba435fd6a5728e8b">00068</a>   std::vector&lt; cv::Vec4d &gt; <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad78028097b1c964cba435fd6a5728e8b">CameraPinholeDistor::convertFromImageTo3Dray</a>( 
<a name="l00069"></a>00069     std::vector&lt; cv::Vec3d &gt; points )
<a name="l00070"></a>00070   {
<a name="l00071"></a>00071     <span class="comment">//TODO</span>
<a name="l00072"></a>00072     <span class="keywordflow">return</span> vector&lt;Vec4d&gt;( );
<a name="l00073"></a>00073   }
<a name="l00074"></a>00074 
<a name="l00075"></a><a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#a4599ad282967c60bc4e3046067202b56">00075</a>   vector&lt;Vec2d&gt; <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#a4599ad282967c60bc4e3046067202b56">CameraPinholeDistor::pixelToNormImageCoordinates</a>(
<a name="l00076"></a>00076     std::vector&lt; cv::Vec2d &gt; points )<span class="keyword"> const</span>
<a name="l00077"></a>00077 <span class="keyword">  </span>{
<a name="l00078"></a>00078     vector&lt;Vec2d&gt; undistordedPoints;
<a name="l00079"></a>00079     <span class="comment">//rectify the distorion, but keep points in pixels coordinates:</span>
<a name="l00080"></a>00080     cv::undistortPoints( points,undistordedPoints,this-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html#ac60a2fb4ca15534d0b361628837f9286" title="store intra parameters( 3*3 matrix ). This matrix contains focal informations, principal point coordi...">intra_params_</a>,this-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#af9ce33321472dbbb71668b266225060b" title="vector of distortion coefficients ( k_1, k_2, p_1, p_2[ , k_3[ , k_4, k_5, k_6 ]] ) of 4...">distortionVector</a> );
<a name="l00081"></a>00081     <span class="keywordflow">return</span> undistordedPoints;
<a name="l00082"></a>00082   }
<a name="l00083"></a>00083 
<a name="l00084"></a><a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ab2ef67d6d89fc008c5716c7f7a25d012">00084</a>   vector&lt;Vec2d&gt; <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ab2ef67d6d89fc008c5716c7f7a25d012">CameraPinholeDistor::normImageToPixelCoordinates</a>( 
<a name="l00085"></a>00085     std::vector&lt;cv::Vec2d&gt; points )<span class="keyword"> const</span>
<a name="l00086"></a>00086 <span class="keyword">  </span>{
<a name="l00087"></a>00087 
<a name="l00088"></a>00088     vector&lt;Vec2d&gt; redistortedPoints;
<a name="l00089"></a>00089 
<a name="l00090"></a>00090     <span class="keywordtype">double</span> r2, icdist, deltaX, deltaY;
<a name="l00091"></a>00091     <span class="keywordtype">double</span> xn, yn, xc, yc;
<a name="l00092"></a>00092 
<a name="l00093"></a>00093     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; points.size(); i++) {
<a name="l00094"></a>00094         <span class="comment">// Extract normalized, undistorted point co-ordinates</span>
<a name="l00095"></a>00095         xn = points.at(i)[0];
<a name="l00096"></a>00096         yn = points.at(i)[1];
<a name="l00097"></a>00097 
<a name="l00098"></a>00098         <span class="comment">//printf(&quot;%s &lt;&lt; (xn, yn) = (%f, %f)\n&quot;, __FUNCTION__, xn, yn);</span>
<a name="l00099"></a>00099 
<a name="l00100"></a>00100         <span class="comment">// Determine radial distance from centre</span>
<a name="l00101"></a>00101         r2 = xn*xn + yn*yn;
<a name="l00102"></a>00102 
<a name="l00103"></a>00103         <span class="comment">// Determine distortion factors (might only work for rational model at this stage)</span>
<a name="l00104"></a>00104         icdist = (1 + ((<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[5]*r2 + <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[4])*r2 + <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[3])*r2)/
<a name="l00105"></a>00105           (1 + ((<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[2]*r2 + <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[1])*r2 + <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[0])*r2);
<a name="l00106"></a>00106         deltaX = 2*<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ae09ea3c12a8e19788d084b357f11a902" title="used to store tangential dist parameters ( /f$p_1/f$ and /f$p_2/f$ )">tangential_dist_</a>[0]*xn*yn + <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ae09ea3c12a8e19788d084b357f11a902" title="used to store tangential dist parameters ( /f$p_1/f$ and /f$p_2/f$ )">tangential_dist_</a>[1]*(r2 + 2*xn*xn);
<a name="l00107"></a>00107         deltaY = <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ae09ea3c12a8e19788d084b357f11a902" title="used to store tangential dist parameters ( /f$p_1/f$ and /f$p_2/f$ )">tangential_dist_</a>[0]*(r2 + 2*yn*yn) + 2*<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ae09ea3c12a8e19788d084b357f11a902" title="used to store tangential dist parameters ( /f$p_1/f$ and /f$p_2/f$ )">tangential_dist_</a>[1]*xn*yn;
<a name="l00108"></a>00108 
<a name="l00109"></a>00109         <span class="comment">// Distort the points, but keep them in normalized co-ordinate system</span>
<a name="l00110"></a>00110         xc = (xn/icdist) + deltaX;
<a name="l00111"></a>00111         yc = (yn/icdist) + deltaY;
<a name="l00112"></a>00112 
<a name="l00113"></a>00113         redistortedPoints.push_back(cv::Point2d(xc, yc));
<a name="l00114"></a>00114 
<a name="l00115"></a>00115         <span class="comment">//printf(&quot;%s &lt;&lt; (xc, yc) = (%f, %f)\n&quot;, __FUNCTION__, xc, yc);</span>
<a name="l00116"></a>00116 
<a name="l00117"></a>00117     }
<a name="l00118"></a>00118 
<a name="l00119"></a>00119     <span class="comment">// Convert these re-distorted but normalized points back to pixel co-ordinates</span>
<a name="l00120"></a>00120     vector&lt;Vec2d&gt; pointsPixelCoord =
<a name="l00121"></a>00121       <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ab2ef67d6d89fc008c5716c7f7a25d012">CameraPinhole::normImageToPixelCoordinates</a>( redistortedPoints );
<a name="l00122"></a>00122 
<a name="l00123"></a>00123     <span class="keywordflow">return</span> pointsPixelCoord;
<a name="l00124"></a>00124   }
<a name="l00125"></a>00125 
<a name="l00126"></a><a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#a449b7e76f4e82b50b38f01457fdfa77b">00126</a>   cv::Ptr&lt;Camera&gt; <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#a449b7e76f4e82b50b38f01457fdfa77b">CameraPinholeDistor::read</a>( <span class="keyword">const</span> cv::FileNode&amp; node )
<a name="l00127"></a>00127   {
<a name="l00128"></a>00128     std::string myName=node.name( );
<a name="l00129"></a>00129     <span class="keywordflow">if</span>( myName != <span class="stringliteral">&quot;CameraPinholeDistor&quot;</span> )
<a name="l00130"></a>00130     {
<a name="l00131"></a>00131       std::string error = <span class="stringliteral">&quot;CameraPinholeDistor FileNode is not correct!\n&quot;</span>
<a name="l00132"></a>00132         <span class="stringliteral">&quot;Expected \&quot;CameraPinholeDistor\&quot;, got &quot;</span>;
<a name="l00133"></a>00133       error += node.name();
<a name="l00134"></a>00134       CV_Error( CV_StsError, error.c_str() );
<a name="l00135"></a>00135     }
<a name="l00136"></a>00136 
<a name="l00137"></a>00137     Mat intra_params;
<a name="l00138"></a>00138     Vec6d radial_dist;
<a name="l00139"></a>00139     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> nbRadialParam;
<a name="l00140"></a>00140     cv::Vec2d tangential_dist;
<a name="l00141"></a>00141 
<a name="l00142"></a>00142     <span class="comment">//load intra parameters:</span>
<a name="l00143"></a>00143     cv::Ptr&lt;Camera&gt; cam_tmp = <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#a449b7e76f4e82b50b38f01457fdfa77b">CameraPinhole::read</a>( node[<span class="stringliteral">&quot;CameraPinhole&quot;</span>] );
<a name="l00144"></a>00144 
<a name="l00145"></a>00145     node[ <span class="stringliteral">&quot;nb_radial_params_&quot;</span> ] &gt;&gt; nbRadialParam;
<a name="l00146"></a>00146     <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i&lt;nbRadialParam;i++)
<a name="l00147"></a>00147       radial_dist[i] = node[ <span class="stringliteral">&quot;radial_dist_&quot;</span> ][i];
<a name="l00148"></a>00148     <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=nbRadialParam;i&lt;6;i++)
<a name="l00149"></a>00149       radial_dist[i] = 0;
<a name="l00150"></a>00150 
<a name="l00151"></a>00151     <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i&lt;2;i++)
<a name="l00152"></a>00152       tangential_dist[i] = node[ <span class="stringliteral">&quot;tangential_dist_&quot;</span> ][i];
<a name="l00153"></a>00153 
<a name="l00154"></a>00154     <span class="keywordflow">return</span> cv::Ptr&lt;Camera&gt;( <span class="keyword">new</span> <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad58c8fb16fdbb0eba4345cd3abe47a92">CameraPinholeDistor</a>(
<a name="l00155"></a>00155       ((<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html" title="This class represent the physical device which take the pictures. It is not related to a 3D position ...">CameraPinhole</a>*)((<a class="code" href="class_opencv_sf_m_1_1_camera.html" title="This class represent the physical device which take the pictures. It is not related to a 3D position ...">Camera</a>*)cam_tmp))-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html#a46eae27e8e2d4f25f1c64fa4d2d9b1eb">getIntraMatrix</a>(),
<a name="l00156"></a>00156       radial_dist, nbRadialParam, tangential_dist) );
<a name="l00157"></a>00157   }
<a name="l00158"></a>00158 
<a name="l00159"></a><a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#a7a481f4ed67f33cc50369729fdf87f84">00159</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#a7a481f4ed67f33cc50369729fdf87f84">CameraPinholeDistor::write</a>( cv::FileStorage&amp; fs )<span class="keyword"> const</span>
<a name="l00160"></a>00160 <span class="keyword">  </span>{
<a name="l00161"></a>00161     fs &lt;&lt; <span class="stringliteral">&quot;CameraPinholeDistor&quot;</span> &lt;&lt; <span class="stringliteral">&quot;{&quot;</span>;
<a name="l00162"></a>00162 
<a name="l00163"></a>00163     ((<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole.html" title="This class represent the physical device which take the pictures. It is not related to a 3D position ...">CameraPinhole</a>*)<span class="keyword">this</span>)-&gt;write( fs );
<a name="l00164"></a>00164 
<a name="l00165"></a>00165     fs &lt;&lt; <span class="stringliteral">&quot;radial_dist_&quot;</span> &lt;&lt; <span class="stringliteral">&quot;[:&quot;</span>;
<a name="l00166"></a>00166     <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i&lt;6;i++)
<a name="l00167"></a>00167       fs &lt;&lt; this-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ad3b352db4b127864bcd901e11d7e50dc" title="used to store radial dist parameters ( /f$k_1/f$ to /f$k_6/f$ )">radial_dist_</a>[i];
<a name="l00168"></a>00168     fs &lt;&lt; <span class="stringliteral">&quot;]&quot;</span>;
<a name="l00169"></a>00169 
<a name="l00170"></a>00170     fs &lt;&lt; <span class="stringliteral">&quot;nb_radial_params_&quot;</span> &lt;&lt; this-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#a99247804700d8c8bfaf50a4e84cfb080" title="number of radial dist parameters ( 0, 2, 3 or 6 )">nb_radial_params_</a>;
<a name="l00171"></a>00171     fs &lt;&lt; <span class="stringliteral">&quot;tangential_dist_&quot;</span> &lt;&lt; <span class="stringliteral">&quot;[:&quot;</span>;
<a name="l00172"></a>00172     <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i&lt;2;i++)
<a name="l00173"></a>00173       fs &lt;&lt; this-&gt;<a class="code" href="class_opencv_sf_m_1_1_camera_pinhole_distor.html#ae09ea3c12a8e19788d084b357f11a902" title="used to store tangential dist parameters ( /f$p_1/f$ and /f$p_2/f$ )">tangential_dist_</a>[i];
<a name="l00174"></a>00174     fs &lt;&lt; <span class="stringliteral">&quot;]&quot;</span>;
<a name="l00175"></a>00175     fs &lt;&lt; <span class="stringliteral">&quot;}&quot;</span>;
<a name="l00176"></a>00176   }
<a name="l00177"></a>00177 }
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Sun Aug 21 2011 16:45:52 for GSoC2011SfM by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
